package com.magic.smartcity.view.adapters;

import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.magic.smartcity.R;
import com.magic.smartcity.beans.BalanceBean;

import java.util.ArrayList;
import java.util.List;

/**
 * @description:
 * @create: Create by Magic on 2022/2/12.
 */
public class MeBalanceListAdapter extends RecyclerView.Adapter<MeBalanceListAdapter.ItemHolder> {
    private static final String TAG = MeBalanceListAdapter.class.getSimpleName();

    private List<BalanceBean> mBeanList = new ArrayList<>();

    @NonNull
    @Override
    public ItemHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_me_balance_list, parent, false);
        return new ItemHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull ItemHolder holder, int position) {
        TextView type = holder.itemView.findViewById(R.id.type);
        TextView money = holder.itemView.findViewById(R.id.money);
        TextView create_time = holder.itemView.findViewById(R.id.create_time);
        type.setText(mBeanList.get(position).getChangeType()+": ");
        money.setText(mBeanList.get(position).getChangeAmount()+"");
        create_time.setText("成交时间: "+mBeanList.get(position).getChangeTime());
    }

    @Override
    public int getItemCount() {
        Log.d(TAG,"balanceListSIZE===="+mBeanList.size());
        return mBeanList.size();
    }

    public class ItemHolder extends RecyclerView.ViewHolder {
        public ItemHolder(@NonNull View itemView) {
            super(itemView);
        }
    }

    public void setData(List<BalanceBean> beanList){
        mBeanList.clear();
        mBeanList.addAll(beanList);
        notifyDataSetChanged();
    }
}
